package com.oocl.customer.servlet;

import java.io.IOException;
import java.lang.reflect.Method;

import javax.net.ssl.HttpsURLConnection;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BaseServlet extends HttpServlet{
	private static final long serialVersionUID = 1L;

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");    // 处理响应编码
		request.setCharacterEncoding("UTF-8");

		String methodName = request.getParameter("method");
		Method method = null;

		try {
			method = this.getClass().getMethod(methodName,
					HttpServletRequest.class, HttpServletResponse.class);
		} catch (Exception e) {
			throw new RuntimeException("method：" + methodName + "dosen exits！", e);
		}		
			try { 
				method.invoke(this, request, response);
			} catch (Exception e) {
				throw new RuntimeException(e);
			} 
		
		
	}
}
